package cn.itlaobing.Dao;

import cn.itlaobing.Util.JdbcPramarter;
import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;

public class BaseDao {
    private DataSource dataSource=null;

    /**
     * 创建连接池
     * @return
     */
    protected DataSource getDataSource() {
        if (dataSource!=null){
            return dataSource;
        }
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(JdbcPramarter.URL);
        dataSource.setDriverClassName(JdbcPramarter.DRIVER);
        dataSource.setUsername(JdbcPramarter.USER);
        dataSource.setPassword(JdbcPramarter.PWD);
        this.dataSource=dataSource;
        return dataSource;
    }
}

